package br.edu.ufcg.lsd.wbis.control.util;

import org.junit.Test;

import br.edu.ufcg.lsd.wbis.control.exception.BusinessValidationException;

/**
 * Tests for class AbstractValidator
 * 
 * @author Renato Miceli - renato@lsd.ufcg.edu.br
 * @see AbstractValidator
 */
public class AbstractValidatorTest {

	@Test(expected = BusinessValidationException.class)
	public void validateNullString() throws BusinessValidationException {
		AbstractValidator.validateNotNullNorBlank(null);
	}

	@Test(expected = BusinessValidationException.class)
	public void validateBlankString_1() throws BusinessValidationException {
		AbstractValidator.validateNotNullNorBlank("");
	}

	@Test(expected = BusinessValidationException.class)
	public void validateBlankString_2() throws BusinessValidationException {
		AbstractValidator.validateNotNullNorBlank(" ");
	}

	@Test(expected = BusinessValidationException.class)
	public void validateBlankString_3() throws BusinessValidationException {
		AbstractValidator.validateNotNullNorBlank("  ");
	}

	@Test(expected = BusinessValidationException.class)
	public void validateBlankString_4() throws BusinessValidationException {
		AbstractValidator.validateNotNullNorBlank("   ");
	}

	@Test(expected = BusinessValidationException.class)
	public void validateBlankString_5() throws BusinessValidationException {
		AbstractValidator.validateNotNullNorBlank("            ");
	}

	@Test(expected = BusinessValidationException.class)
	public void validateBlankString_6() throws BusinessValidationException {
		AbstractValidator.validateNotNullNorBlank("                                       ");
	}

	@Test
	public void validateNeitherNullNorBlankStrings() throws BusinessValidationException {
		AbstractValidator.validateNotNullNorBlank("a");
		AbstractValidator.validateNotNullNorBlank("asdasd");
		AbstractValidator.validateNotNullNorBlank("a a");
		AbstractValidator.validateNotNullNorBlank("1");
		AbstractValidator.validateNotNullNorBlank("123123");
		AbstractValidator.validateNotNullNorBlank("1 1");
		AbstractValidator.validateNotNullNorBlank("a1s2d3");
		AbstractValidator.validateNotNullNorBlank("1a2s3d");
		AbstractValidator.validateNotNullNorBlank("  asd  ");
		AbstractValidator.validateNotNullNorBlank("  123  ");
		AbstractValidator.validateNotNullNorBlank("  12 12  ");
		AbstractValidator.validateNotNullNorBlank("  as as  ");
		AbstractValidator.validateNotNullNorBlank("Asas12SS  ");
		AbstractValidator.validateNotNullNorBlank("  fgWSD123");
	}

}
